package com.pgeg.effect;

import com.pgeg.api.mana.IManaHandler;
import com.pgeg.config.ModConfig;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectType;
import net.minecraft.entity.player.PlayerEntity;

public class ManaReductionStatusEffect extends StatusEffect {

    private static final float REDUCTION_AMOUNT = 0.5f;

    public ManaReductionStatusEffect() {
        super(StatusEffectType.HARMFUL,0x98D982);
    }

    @Override
    public boolean canApplyUpdateEffect(int duration, int amplifier) {
        return true;
    }

    @Override
    public void applyUpdateEffect(LivingEntity entity, int amplifier) {
            if (entity instanceof PlayerEntity) {
                if (!((PlayerEntity) entity).getAbilities().creativeMode && ModConfig.enableManaReduction) {
                    ((IManaHandler) entity).reduceMana(REDUCTION_AMOUNT);
            }
        }
        super.applyUpdateEffect(entity, amplifier);
    }
}
